Conditions | 4 |
Total Lines | 20 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Tests | 4 |
CRAP Score | 4.128 |
Changes | 0 |
1 | 1 | const db = require("../db/database.js"); |
|
4 | function getDeliveries(res, apiKey) { |
||
5 | 2 | const sql = "SELECT deliveryId as id, productId as product_id, amount," + |
|
6 | " deliveryDate as delivery_date, comment" + |
||
7 | " FROM deliveries WHERE apiKey = ?"; |
||
8 | |||
9 | 2 | db.all(sql, apiKey, (err, rows) => { |
|
10 | 2 | if (err) { |
|
11 | return res.status(500).json({ |
||
12 | errors: { |
||
13 | status: 500, |
||
14 | source: "/deliveries", |
||
15 | title: "Database error", |
||
16 | detail: err.message |
||
17 | } |
||
18 | }); |
||
19 | } else { |
||
|
|||
20 | 2 | res.json({ data: rows }); |
|
21 | } |
||
22 | }); |
||
23 | } |
||
24 | |||
56 |